<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                
<ui:define name="body">

	<h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
	
	<h:form id="falta">
		
		<rich:panel>
			<f:facet name="header">#{faltaHome.managed ? messages['application.label.edit'] : messages['application.label.add']} #{messages['application.falta.label']}</f:facet>
			
			<s:decorate id="turmaDecoration" template="layout/edit.xhtml">
				<ui:define name="label">#{messages['application.turma.label']}</ui:define>
				<h:selectOneMenu id="turmaSelect" value="#{faltaHome.instance.turma}">
					<s:selectItems value="#{faltaHome.listTurma}" var="turma" label="#{turma.codTurma}" noSelectionLabel="" />
					<s:convertEntity />
					<a:support event="onchange" action="#{faltaHome.loadDisciplinaSelect}" reRender="disciplinaSelect" />
				</h:selectOneMenu>
			</s:decorate>
			
			<s:decorate id="disciplinaDecoration" template="layout/edit.xhtml">
				<ui:define name="label">#{messages['application.disciplina.label']}</ui:define>
				<h:selectOneMenu id="disciplinaSelect" value="#{faltaHome.instance.disciplina}">
					<s:selectItems value="#{faltaHome.listDisciplina}" var="disc" label="#{disc.nomDisciplina}" noSelectionLabel="" />
					<s:convertEntity />
					<a:support event="onchange" action="#{faltaHome.loadFaltaItemList}" reRender="faltaItemList" />
				</h:selectOneMenu>
			</s:decorate>
			
			<s:decorate id="dataFaltaDecoration" template="layout/edit.xhtml">
				<ui:define name="label">#{messages['application.falta.label.data']}</ui:define>
				<rich:calendar
					id="dataFalta"
					value="#{faltaHome.instance.datFalta}"
					datePattern="dd/MM/yyyy" />
			</s:decorate>
			
			<div style="clear:both">
                <span class="required">*</span>
                #{messages['application.label.requiredfiels']} 
            </div>
			
		</rich:panel>
		
		<div class="actionButtons">

            <h:commandButton id="save" 
                          value="#{messages['application.label.saveCreate']}" 
                         action="#{faltaHome.preparePersist}"
                       rendered="#{!faltaHome.managed}"/>  
                          			  
            <h:commandButton id="update" 
                          value="#{messages['application.label.saveUpdate']}" 
                         action="#{faltaHome.prepareUpdate}"
                       rendered="#{faltaHome.managed}"/>
                        			  
            <h:commandButton id="delete" 
                          value="#{messages['application.label.delete']}" 
                         action="#{faltaHome.remove}"
                       rendered="#{faltaHome.managed}"/>
                    
            <s:button id="done" 
                   value="#{messages['application.label.done']}"
             propagation="end"
                    view="/Falta.xhtml"
                rendered="#{faltaHome.managed}"/>
                
            <s:button id="cancel" 
                   value="#{messages['application.label.cancel']}"
             propagation="end"
                    view="/#{empty faltaFrom ? 'FaltaList' : faltaFrom}.xhtml"
                rendered="#{!faltaHome.managed}"/>

        </div>
        
		<rich:dataTable
				id="faltaItemList"
				var="falta"
				value="#{faltaHome.listFaltaItem}"
				columnsWidth="80%,20%">
			<h:column>
				<f:facet name="header">#{messages['application.aluno.label']}</f:facet>
				#{falta.aluno.nomAluno}
			</h:column>
			<h:column>
				<f:facet name="header">#{messages['application.falta.label.qtdfalta']}</f:facet>
				<h:inputText value="#{falta.numQtdFalta}" />
			</h:column>
		</rich:dataTable>
	</h:form>

</ui:define>
                
</ui:composition>